package com.sc.weixin.member;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.sc.dal.model.member.Member;
import com.sc.dal.model.order.Orders;
import com.sc.service.member.MemberService;
import com.sc.service.order.OrderService;
import com.sc.util.data.SessionContainer;


@Controller
@RequestMapping(value="personal")
public class PersonalController {
	@Autowired
	private OrderService orderService;
	@Autowired
	private MemberService memberService;
	
	@RequestMapping(value="/initPersonal")
	public Object initPersonal(HttpServletRequest request){
		ModelAndView mav = new ModelAndView("/member/personal");
		Member member = SessionContainer.getSessionMember(request);
		if(member != null){
			Member memberExt = memberService.selectByPrimaryKey(member.getmId());
			mav.addObject("member", memberExt);
			Orders order = new Orders();
//			 添加查询条件
			order.setMemberId(member.getmId());
			//订单查询状态 0：全部,1：待付款,2:待发货，3:待收货，4：待评价 ，5：退换货 
			order.setQueryStatus("0");
			int queryStatus0count =orderService.counts(order);
			order.setQueryStatus("1");
			int queryStatus1count =orderService.counts(order);			
			order.setQueryStatus("2");
			int queryStatus2count =orderService.counts(order);			
			order.setQueryStatus("3");
			int queryStatus3count =orderService.counts(order);
			order.setQueryStatus("4");
			int queryStatus4count =orderService.counts(order);
			order.setQueryStatus("5");
			int queryStatus5count =orderService.counts(order);
			mav.addObject("queryStatus0count", queryStatus0count);
			mav.addObject("queryStatus1count", queryStatus1count);
			mav.addObject("queryStatus2count", queryStatus2count);
			mav.addObject("queryStatus3count", queryStatus3count);
			mav.addObject("queryStatus4count", queryStatus4count);
			mav.addObject("queryStatus5count", queryStatus5count);
		}
		return mav;
	}
	@RequestMapping(value="/setUp")
	public Object setUp(){
		ModelAndView mav = new ModelAndView("/member/setUp");
		return mav;
	}
}
